#include <iostream>
#include <string>

class Device
{
protected:
    std::string name;
public:
    Device(std::string name)
    {
        Device::name = name;
    }
    virtual bool isEnabled() = 0;
    virtual void enable() = 0;
    virtual void disable() = 0;
    virtual int getVolume() = 0;
    virtual void setVolume(int percent) = 0;
    virtual int getChannel() = 0;
    virtual void setChannel(int channel) = 0;
};

class RemoteControl
{
protected:
    Device* device = nullptr;
public:
    RemoteControl(Device* device)
    {
        RemoteControl::device = device;
    }
    void togglePower()
    {
        if(device->isEnabled())
        {
            device->disable();
        }else{
            device->enable();
        }
    }
    void volumeDown()
    {
        device->setVolume(device->getVolume() - 10);
    }
    void volumeUp()
    {
        device->setVolume(device->getVolume() + 10);
    }
    void channelDown()
    {
        device->setChannel(device->getChannel() - 1);
    }
    void channelUp()
    {
        device->setChannel(device->getChannel() + 1);
    }
};

class TV : public Device
{
private:
    int channel = 0;
    int volume  = 0;
    bool power = false;
public:
    TV(std::string name)
            :Device(name)
    {

    }
    bool isEnabled() override
    {
        return power;
    }
    void enable() override
    {
        std::cout<<"TV enable"<<std::endl;
        power = true;
    }
    void disable() override
    {
        std::cout<<"TV disable"<<std::endl;
        power = false;
    }
    int getVolume() override
    {
        return volume;
    }
    void setVolume(int percent) override
    {
        std::cout<<"TV set volume to "<<percent<<std::endl;
        volume = percent;
    }
    int getChannel() override
    {
        return channel;
    }
    void setChannel(int channel) override
    {
        std::cout<<"TV set channel to "<<channel<<std::endl;
        TV::channel = channel;
    }
};

class Radio : public Device
{
private:
    int channel = 0;
    int volume  = 0;
    bool power = false;
public:
    Radio(std::string name)
    :Device(name)
    {

    }
    bool isEnabled() override
    {
        return power;
    }
    void enable() override
    {
        std::cout<<"Radio enable"<<std::endl;
        power = true;
    }
    void disable() override
    {
        std::cout<<"Radio disable"<<std::endl;
        power = false;
    }
    int getVolume() override
    {
        return volume;
    }
    void setVolume(int percent) override
    {
        std::cout<<"Radio set volume to "<<percent<<std::endl;
        volume = percent;
    }
    int getChannel() override
    {
        return channel;
    }
    void setChannel(int channel) override
    {
        std::cout<<"Radio set channel to "<<channel<<std::endl;
        Radio::channel = channel;
    }
};

class AdvancedRemoteControl : public RemoteControl
{
public:
    AdvancedRemoteControl(Device* device)
        :RemoteControl(device)
    {

    }
    void mute()
    {
        device->setVolume(0);
    }
};

int main() {
    Radio* radio = new Radio("Radio");
    AdvancedRemoteControl *remote = new AdvancedRemoteControl(radio);
    remote->mute();
    return 0;
}





